<meta charset="utf-8">
(#) Behavior change when requesting photo library access

!!! WARNING: Behavior change when requesting photo library access
   This is a warning.

Id
:   `SelectedPhotoAccess`
Summary
:   Behavior change when requesting photo library access
Severity
:   Warning
Category
:   Correctness
Platform
:   Android
Vendor
:   Android Open Source Project
Feedback
:   https://issuetracker.google.com/issues/new?component=192708
Since
:   8.3.0 (February 2024)
Affects
:   Manifest files
Editing
:   This check runs on the fly in the IDE editor
See
:   https://developer.android.com/about/versions/14/changes/partial-photo-video-access
Implementation
:   [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/SelectedPhotoAccessDetector.kt)
Tests
:   [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/SelectedPhotoAccessDetectorTest.kt)

Selected Photo Access is a new ability for users to share partial access
to their photo library when apps request access to their device storage
on Android 14+.

Instead of letting the system manage the selection lifecycle, we
recommend you adapt your app to handle partial access to the photo
library.

(##) Example

Here is an example of lint warnings produced by this check:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
AndroidManifest.xml:11:Warning: Your app is currently not handling
Selected Photos Access introduced in Android 14+ [SelectedPhotoAccess]
    &lt;uses-permission android:name="android.permission.READ_MEDIA_IMAGES" android:minSdkVersion="33" /&gt;
                                   ------------------------------------
AndroidManifest.xml:13:Warning: Your app is currently not handling
Selected Photos Access introduced in Android 14+ [SelectedPhotoAccess]
    &lt;uses-permission android:name="android.permission.READ_MEDIA_VIDEO" android:minSdkVersion="33"/&gt;
                                   -----------------------------------
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here is the source file referenced above:

`AndroidManifest.xml`:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~xml linenumbers
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="foo.bar"
    android:versionCode="990000000"
    android:versionName="9.1.0.0.0x"&gt;

    &lt;uses-sdk android:minSdkVersion="14" android:targetSdkVersion="34" /&gt;

    &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="32"/&gt;
    &lt;!-- Media permissions introduced in Android 13 (T) --&gt;
    &lt;uses-permission android:name="android.permission.READ_MEDIA_IMAGES" android:minSdkVersion="33" /&gt;
    &lt;uses-permission android:name="android.permission.READ_MEDIA_AUDIO" android:minSdkVersion="33" /&gt;
    &lt;uses-permission android:name="android.permission.READ_MEDIA_VIDEO" android:minSdkVersion="33"/&gt;
    &lt;uses-permission android:name="android.permission.CAMERA" /&gt;

    &lt;application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:permission="android.permission.READ_CONTACTS"&gt;
    &lt;/application&gt;

&lt;/manifest&gt;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can also visit the
[source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/SelectedPhotoAccessDetectorTest.kt)
for the unit tests for this check to see additional scenarios.

(##) Suppressing

You can suppress false positives using one of the following mechanisms:

* Adding the suppression attribute
  `tools:ignore="SelectedPhotoAccess"` on the problematic XML element
  (or one of its enclosing elements). You may also need to add the
  following namespace declaration on the root element in the XML file
  if it's not already there:
  `xmlns:tools="http://schemas.android.com/tools"`.

* Using a special `lint.xml` file in the source tree which turns off
  the check in that folder and any sub folder. A simple file might look
  like this:
  ```xml
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;lint&gt;
      &lt;issue id="SelectedPhotoAccess" severity="ignore" /&gt;
  &lt;/lint&gt;
  ```
  Instead of `ignore` you can also change the severity here, for
  example from `error` to `warning`. You can find additional
  documentation on how to filter issues by path, regular expression and
  so on
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).

* In Gradle projects, using the DSL syntax to configure lint. For
  example, you can use something like
  ```gradle
  lintOptions {
      disable 'SelectedPhotoAccess'
  }
  ```
  In Android projects this should be nested inside an `android { }`
  block.

* For manual invocations of `lint`, using the `--ignore` flag:
  ```
  $ lint --ignore SelectedPhotoAccess ...`
  ```

* Last, but not least, using baselines, as discussed
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).

<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>